home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: realloc question
- Date: Tue, 30 Jan 96 14:58:00 GMT
- Organization: none
- Message-ID: <823013880snz@genesis.demon.co.uk>
- References: <4ehi4b$qfo@news.texas.net> <QG28B81O@gellbo.gellrich-gmbh.de>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <QG28B81O@gellbo.gellrich-gmbh.de>
- wolfi@gellbo.gellrich-gmbh.de "Actio wolfi" writes:
-
- > if(NULL == (ptr = no_elements ?
- > \
- > (typ *)realloc((char *)ptr,
- > \
- > (unsigned)(no_allocated +=
- > increment) * sizeof(typ)) : \
-
- In many cases a geometric increase makes more sense e.g.
-
- no_allocated *= 2
-
- or if you find that excessive perhaps:
-
- no_allocated += no_allocated/2
-
- > (typ *)malloc(sizeof(typ) * (no_allocated =
- > increment)))) \
-
- Of course no_callocated must be initialised to a nonzero value
-
- no_allocated = INITIAL_VALUE
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-